import java.util.concurrent.*;

/**
 * @author lzm
 * @date 2025/2/28 18:40
 * @description
 */
public class CustomThreadPool extends ThreadPoolExecutor {


    public CustomThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler) {
        super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, handler);
    }

    @Override
    protected void beforeExecute(Thread t, Runnable r) {
        System.out.println(t.getName() + "准备开始执行任务：" + r.getClass() + "，当前线程的状态为：" + t.getState().name());
    }

    @Override
    protected void afterExecute(Runnable r, Throwable t) {
        System.out.println(r.getClass() + "执行完毕，当前线程的状态为：" + Thread.currentThread().getState().name());
    }

}
